package Stubs;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import Exceptions.InvalidAgeParam;
import Exceptions.InvalidCapacity;
import Exceptions.InvalidChildID;
import Exceptions.InvalidHeightParam;
import Exceptions.InvalidRideId;
import Exceptions.InvalidRideName;
import Exceptions.TicketDoesntExist;
import Exceptions.XMLRidesParserException;
import Exceptions.CentralComputerExceptions.ChildAgeDoesntMatch;
import Exceptions.CentralComputerExceptions.ChildDoesntHaveTicket;
import Exceptions.CentralComputerExceptions.ChildHeightDoesntMatch;
import Exceptions.CentralComputerExceptions.ChildIDDoesntExist;
import Exceptions.CentralComputerExceptions.ErrorInGuardianPassword;
import Exceptions.CentralComputerExceptions.GuardianIDDoesntExist;
import Exceptions.CentralComputerExceptions.InvalidPassword;
import Exceptions.CentralComputerExceptions.RideIDDoesntExist;
import sourceFiles.ChildEntry;
import sourceFiles.GuardianEntry;
import sourceFiles.ICentralComputer;
import sourceFiles.ETicket;
import sourceFiles.IRide;
import sourceFiles.RideEntry;
import sourceFiles.SupervisorStation;
import sourceFiles.XMLRidesParser;
/**
 * @author LASO-Team
 *
 */
public class CentralComputerStub3 implements ICentralComputer {

	private LinkedList<Integer> maxCapacityList, minAgeList, minHeightList,
			rideIDList, childIDList, actualChildHeightList, actualChildAgeList;
	private LinkedList<String> rideNameList;
	private LinkedList<Boolean> isExtremeRideList;
	private boolean hasATicket;

	public LinkedList<Integer> getActualHeightList() {
		return actualChildHeightList;
	}

	public void setActualHeightList(LinkedList<Integer> tooShortHeightList) {
		this.actualChildHeightList = tooShortHeightList;
	}

	public LinkedList<Integer> getActualChildAge() {
		return actualChildAgeList;
	}

	public void setActualChildAge(LinkedList<Integer> tooYoungAgeList) {
		this.actualChildAgeList = tooYoungAgeList;
	}

	public LinkedList<Integer> getChildIDList() {
		return childIDList;
	}

	public void setChildIDList(LinkedList<Integer> childIDList) {
		this.childIDList = childIDList;
	}

	public void setMaxCapacityList(LinkedList<Integer> maxCapacityList) {
		this.maxCapacityList = maxCapacityList;
	}

	public void setMinAgeList(LinkedList<Integer> minAgeList) {
		this.minAgeList = minAgeList;
	}

	public void setMinHeightList(LinkedList<Integer> minHeightList) {
		this.minHeightList = minHeightList;
	}

	public void setRideIDList(LinkedList<Integer> rideIDList) {
		this.rideIDList = rideIDList;
	}

	public void setRideNameList(LinkedList<String> rideNameList) {
		this.rideNameList = rideNameList;
	}

	public void setIsExtremeRideList(LinkedList<Boolean> isExtremeRideList) {
		this.isExtremeRideList = isExtremeRideList;
	}

	public LinkedList<Integer> getMaxCapacityList() {
		return maxCapacityList;
	}

	public LinkedList<Integer> getMinAgeList() {
		return minAgeList;
	}

	public LinkedList<Integer> getMinHeightList() {
		return minHeightList;
	}

	public LinkedList<String> getRideNameList() {
		return rideNameList;
	}

	public LinkedList<Boolean> getIsExtremeRideList() {
		return isExtremeRideList;
	}

	public LinkedList<Integer> getRideIDList() {
		return rideIDList;
	}

	public CentralComputerStub3() {
		maxCapacityList = new LinkedList<Integer>();
		minAgeList = new LinkedList<Integer>();
		minHeightList = new LinkedList<Integer>();
		rideIDList = new LinkedList<Integer>();
		rideNameList = new LinkedList<String>();
		isExtremeRideList = new LinkedList<Boolean>();
		childIDList = new LinkedList<Integer>();
		actualChildHeightList = new LinkedList<Integer>();
		actualChildAgeList = new LinkedList<Integer>();

	}

	@Override
	public Integer createRide(String rideName, Boolean isExtremeRide,
			Integer maxCapacity, Integer minAge, Integer minHeight)
			throws InvalidRideName, InvalidCapacity, InvalidAgeParam,
			InvalidHeightParam, XMLRidesParserException {
		rideNameList.add(rideName);
		maxCapacityList.add(maxCapacity);
		minAgeList.add(minAge);
		minHeightList.add(minHeight);
		isExtremeRideList.add(isExtremeRide);
		rideIDList.add(rideIDList.size() + 1);
		return rideIDList.size() + 1;

	}

	@Override
	public void updateRide(Integer rideID, Integer maxCapacity, Integer minAge,
			Integer minHeight) throws InvalidRideId, InvalidRideId,
			InvalidCapacity, InvalidAgeParam, InvalidHeightParam, RideIDDoesntExist {
		if (!rideIDList.contains(rideID))
			throw new RideIDDoesntExist();
		int index = rideIDList.indexOf(rideID);
		maxCapacityList.set(index, maxCapacity);
		minAgeList.set(index, minAge);
		minHeightList.set(index, minHeight);

	}

	@Override
	public String addGuardian(Integer guardianID, Integer billingInfo) {
		return null;
	}

	@Override
	public void addChildToGuardian(Integer guardianID, Integer childID,
			Integer age, Integer height) {

	}

	@Override
	public void connectGuardian(Integer userID, String userPassword)
			throws InvalidPassword, GuardianIDDoesntExist,
			ErrorInGuardianPassword {

	}

	@Override
	public void buyingProcess(Integer rideID, Integer guardianID,
			Integer childID) {

	}

	@Override
	public void performBilling(Double ridePrice, Integer billingInfo) {

	}

	@Override
	public void cancelAcquisition(Integer rideID, Integer guardianID,
			Integer childID) {

	}

	@Override
	public void validateChildForRide(Integer rideID, Integer childID)
			throws ChildIDDoesntExist, InvalidChildID, InvalidRideId,
			ChildHeightDoesntMatch, ChildAgeDoesntMatch, ChildDoesntHaveTicket,
			RideIDDoesntExist, TicketDoesntExist {
		// checks if the ride ID is valid
		if (rideID < 1) {
			throw new InvalidRideId();
		}

		// checks if the child ID is valid
		if (childID < 1) {
			throw new InvalidChildID();
		}
		// finds the ride
		if (!rideIDList.contains(rideID)) {
			throw new RideIDDoesntExist();
		}
		// finds the child
		if (!childIDList.contains(childID)) {
			throw new ChildIDDoesntExist();
		}
		//find current child params in stub lists
		int indexOfChild = -1;
		for (int i = 0; i < childIDList.size(); i++) {
			int currChildID  = childIDList.get(i);
			if (childID == currChildID) {
				indexOfChild = i;
				break;
			}
		}
		int minAge = minAgeList.get(indexOfChild);
		int minHeight = minHeightList.get(indexOfChild);
		int actualChildAge = actualChildAgeList.get(indexOfChild);
		int actualHeightAge = actualChildHeightList.get(indexOfChild);
		
		if(actualChildAge<minAge){
			throw new ChildAgeDoesntMatch();
		}
		if(actualHeightAge < minHeight){
			throw new ChildHeightDoesntMatch();
		}
		if(!hasATicket){
			throw new TicketDoesntExist();
		}
		

	}

	@Override
	public Map<Integer, Integer> retrieveChildrenLocation(Integer guardinID) {
		return null;
	}

	@Override
	public ETicket retrieveChildETicket(Integer childID) {
		return null;
	}

	@Override
	public HashMap<Integer, Integer> getTicketsSold() {
		return null;
	}

	@Override
	public LinkedList<RideEntry> getRidesCatalog() {
		return null;
	}

	@Override
	public XMLRidesParser getParser() {
		return null;
	}

	@Override
	public void setParser(XMLRidesParser parser) {

	}

	@Override
	public void setTicketsSold(HashMap<Integer, Integer> ticketsSold) {

	}

	@Override
	public SupervisorStation getSupervisorStation() {
		return null;
	}

	@Override
	public void setSupervisorStation(SupervisorStation supervisorStation) {

	}

	@Override
	public LinkedList<GuardianEntry> getGuardiansList() {
		return null;
	}

	@Override
	public void setGuardiansList(LinkedList<GuardianEntry> guardiansList) {

	}

	@Override
	public LinkedList<ChildEntry> getChildrenList() {
		return null;
	}

	@Override
	public void setChildrenList(LinkedList<ChildEntry> childrenList) {

	}

	@Override
	public LinkedList<IRide> getRidesList() {
		return null;
	}

	@Override
	public void setRidesList(LinkedList<IRide> ridesList) {

	}

	@Override
	public void setRidesCatalog(LinkedList<RideEntry> ridesCatalog) {

	}

	public boolean isHasATicket() {
		return hasATicket;
	}

	public void setHasATicket(boolean hasATicket) {
		this.hasATicket = hasATicket;
	}

}
